<?php
// Hanterar in och utdata med hjälp av de andra klasserna.
class FileUploadController {
	public function doFileUpload() {
		// Create instances that is needed
		$loginHandler = new LoginHandler();
		$fileUploadHandler = new FileUploadHandler();
		$fileUploadView = new FileUploadView();
		$content = "<div class='inner'>";
		// Add list of files to content-variable
		// If user is logged in, add upload form to content-variable
		if ($loginHandler -> isLoggedIn()) {
			$fileUploadForm = $fileUploadView -> createFileUploadForm();
			$content .= $fileUploadForm;
		}
		// Uploading
		if($fileUploadView->triedToUpload()){
			//echo "laddat upp";
			$content.= $fileUploadView->showFeedback($fileUploadHandler->saveFiles());		
		}
		$content .= $fileUploadView -> listFiles();
		return $content;
	}
}
?>